package com.onlineMIS.ORM.DAO.headQ.inventoryFlow;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.aop.ThrowsAdvice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.onlineMIS.ORM.DAO.BaseDAO;
import com.onlineMIS.ORM.entity.headQ.inventory.InventoryOrderProduct;
import com.onlineMIS.ORM.entity.headQ.inventoryFlow.HeadQInventoryStore;
import com.onlineMIS.common.Common_util;
import com.onlineMIS.common.loggerLocal;

@Repository
public class HeadQInventoryStoreDAOImpl extends BaseDAO<HeadQInventoryStore> {
   
   public HeadQInventoryStore getDefaultStore() throws Exception{
	   return get(HeadQInventoryStore.INVENTORY_STORE_DEFAULT_ID, true);
   }
   
   /**
    * 本剧归属获取库房 
    * @param belongTo
    * @return
    */
   public List<HeadQInventoryStore> getStoresByBelongTo(int belongTo){
		DetachedCriteria criteria = DetachedCriteria.forClass(HeadQInventoryStore.class);
		criteria.add(Restrictions.eq("belongTo", belongTo));		
		List<HeadQInventoryStore> stores = this.getByCritera(criteria, true); 
		return stores;
   }
   
   public static HeadQInventoryStore getDummyAllStore() {
		HeadQInventoryStore headQInventoryStore = new HeadQInventoryStore();
		headQInventoryStore.setId(Common_util.ALL_RECORD);
		headQInventoryStore.setName("所有仓库");
		headQInventoryStore.setComment("所有仓库");
		return headQInventoryStore;

   }


	/**
	 * 获取所有在使用中的总部库房
	 * @return
	 */
	public List<HeadQInventoryStore> getActiveStores() {
		DetachedCriteria criteria = DetachedCriteria.forClass(HeadQInventoryStore.class);
		criteria.add(Restrictions.eq("status",HeadQInventoryStore.NORMAL ));		
		List<HeadQInventoryStore> stores = this.getByCritera(criteria, true); 
		return stores;
	}


}
